home *** CD-ROM | disk | FTP | other *** search
- #include <exec/exec.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- char msgbase[200];
-
- struct MailHeader {
- char Status[1];
- long MsgNumb;
- char ToName[31],
- FromName[31],
- Subject[31];
- long MsgDate,
- Recv;
- char Pad;
- };
- void sr(char *s);
-
- main(int argc,char *argv[])
- {
- int i;
- FILE *fi;
- int lost=0;
- int remit=0;
- ULONG Position;
- struct MailHeader t;
- char headername[200];
- char filename[200];
- if(argc<2)
- {
- printf("\n");
- printf(" .--------------------------------------------------------.\n");
- printf(" | Ami-Express MsgStrip Version 1.1 Written by ByteMaster |\n");
- printf(" | /X Development Team - The Silent Achievers |\n");
- printf(" `--------------------------------------------------------'\n");
- printf("\n");
- printf("usage: MsgStrip <msgbase directory> \n");
- printf(" ie: MsgStrip BBS:PD/msgbase\n");
- printf("\n");
- exit(0);
- }
- if(argc==3) remit=1;
-
- printf("\n");
- printf(" .--------------------------------------------------------.\n");
- printf(" | Ami-Express MsgStrip Version 1.1 Written by ByteMaster |\n");
- printf(" | /X Development Team - The Silent Achievers |\n");
- printf(" `--------------------------------------------------------'\n");
- printf("\n");
-
- strcpy(msgbase,argv[1]);
-
-
- sr(msgbase);
-
- i=strlen(msgbase)-1;
- if(msgbase[i]!=':' && msgbase[i]!='/') strcat(msgbase,"/");
-
- sprintf(headername,"%sheaderfile",msgbase);
-
- Position=0L;
-
- fi=fopen(headername,"r+b");
-
- if(fi==NULL)
- {
- printf("\n");
- printf("Error, can't locate msgbase\n");
- printf("\n");
- exit(0);
- }
-
- printf("\n");
- printf("\n");
- printf("Scanning Message Base for received messages\n\n");
-
- while(fread((APTR)&t,sizeof(struct MailHeader),1,fi)!=NULL)
- {
-
- if(t.Status[0]=='R' && t.Recv!=0)
- {
- sprintf(filename,"%s%d",msgbase,t.MsgNumb);
- if(!access(filename,00))
- {
- printf("Received , Msg number # %ld\n",t.MsgNumb);
- t.Status[0]='D';
- if(remit) { fseek(fi,Position,0L); fwrite((APTR)&t,sizeof(struct MailHeader),1,fi);
- fseek(fi,Position,0L); }
- lost +=1;
- DeleteFile(filename);
- }
-
- }
- Position=ftell(fi);
- }
- fclose(fi);
- if(lost)printf("Total Received messages = %d\n",lost);
- else
- printf("MsgVal reports no lost messages\n\n");
- exit(0);
- }
-
- void sr(char *s)
- {
- register int i;
- i=strlen(s)-1;
- while(i>-1)
- {
- if(*(s+i)<=32) *(s+i)='\0'; else break;
- i--;
- }
- }
-